package com.treasure.mall.biz.service.core.live.impl;

import com.treasure.mall.biz.entity.live.LiveRoomStatisticsPO;
import com.treasure.mall.biz.repository.live.LiveRoomStatisticsRepository;
import com.treasure.mall.biz.service.core.live.LiveRoomStatisticsService;
import com.treasure.mall.zbq.common.ienum.base.CodeDescEnumHelper;
import com.treasure.mall.zbq.common.ienum.live.LiveEnums;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * <p>
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.biz.service.core.live.impl
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/9/19 2:24 下午
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * 
 */
@Service
public class LiveRoomStatisticsServiceImpl implements LiveRoomStatisticsService {
    @Autowired
    private LiveRoomStatisticsRepository repository;


    @Override
    public void add(Long userId, String sessionId, String scene) {
        LiveEnums.SceneType sceneType = CodeDescEnumHelper.getEnumTypeByDesc(LiveEnums.SceneType.class, scene);
        if (sceneType == null) {
            sceneType = LiveEnums.SceneType.miniProgram;
        }
        LiveRoomStatisticsPO statisticsPO = new LiveRoomStatisticsPO();
        statisticsPO.setSceneType(sceneType);
        statisticsPO.setSessionId(sessionId);
        statisticsPO.setUserId(userId);

        repository.save(statisticsPO);
    }
}
